Function Reference

UDPSend

Sends data on an opened socket

UDPSend ( socketarray, data)

 

Parameters

socketarray The main socket/array as returned by a UDPOpen function.
data binary/string to be sent to the connected socket

 

Return Value

Success: Returns number of bytes sent to the opened socket.
Failure: Returns 0 and sets @error according to the WSAGetError Windows API return.
If IPAddr is incorrect @error is set to 1.
If port is incorrect @error is set to 2.

 

Remarks

None.

 

Related

UDPOpen, UDPBind

 

Example


;;This is the UDP Client
;;Start the server first

; Start The UDP Services
;==============================================
UDPStartup()

; Open a "SOCKET"
;==============================================
$socket = UDPOpen("127.0.0.1", 65532)
If @error <> 0 Then Exit

$n=0
While 1
    Sleep(2000)
    $n = $n + 1
    $status = UDPSend($socket, "Message #" & $n)
    If $status = 0 then
        MsgBox(0, "ERROR", "Error while sending UDP message: " & @error)
        Exit
    EndIf
WEnd

Func OnAutoItExit()
    UDPCloseSocket($socket)
    UDPShutdown()
EndFunc